package com.zzh.phone.hviews;

import android.os.Bundle;

import com.zzh.phone.hviews.databinding.ActVpBinding;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;

/**
 * Created by ZZH on 2022/5/24.
 *
 * @Date: 2022/5/24
 * @Email: zzh_hz@126.com
 * @QQ: 1299234582
 * @Author: zzh
 * @Description:
 */
public class VPAct extends AppCompatActivity {
    ActVpBinding inflate;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        inflate = ActVpBinding.inflate(getLayoutInflater());
        setContentView(inflate.getRoot());
        inflate.vp2.setOrientation(ViewPager2.ORIENTATION_VERTICAL);
        //inflate.vp2.setPageTransformer(new FlipHorizontalTransformer());


        inflate.vp2.setAdapter(new FragmentStateAdapter(this) {
            @NonNull
            @Override
            public Fragment createFragment(int position) {
                return ItemFragment.newInstance(position);
            }

            @Override
            public int getItemCount() {
                return 40;
            }
        });

        inflate.vp2.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
                super.onPageScrolled(position, positionOffset, positionOffsetPixels);
            }

            @Override
            public void onPageSelected(int position) {
                super.onPageSelected(position);
            }

            @Override
            public void onPageScrollStateChanged(int state) {
                super.onPageScrollStateChanged(state);
            }
        });

    }
}
